package com.gx.auth.common;

import lombok.Data;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by gx on 2017/4/3.
 */
@Data
public class BaseEntity {
    private Long id;


    /**
     * 传进来实体的list 遍历实体 返回 map  id：实体
     * @param list
     * @param <T>
     * @return
     */
    public static <T extends BaseEntity> Map<Long, T> idEntityMap(Collection<T> list) {
        Map<Long, T> map = new HashMap<Long, T>();
        if (null == list || 0 == list.size()) {
            return map;
        }
        //java 不成文规定
        //List Map Set 制空
        for (T entity : list) {
            map.put(entity.getId(), entity);
        }
        return map;
    }
}
